package com.privatetime.web;

import java.util.Map;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.privatetime.service.CardService;
import com.privatetime.service.GroupService;
import com.privatetime.service.UserService;

public abstract class BaseAction extends ActionSupport implements
		ActionStateConstants {

	protected final Logger logger = Logger.getLogger(getClass());

	private static final long serialVersionUID = 1L;

	protected UserService userService;
	protected CardService cardService;
	protected GroupService groupService;

	protected String failureMessage;

	public String getFailureMessage() {
		return failureMessage;
	}
	
	public void setFailureMessage(String failureMessage) {
		this.failureMessage = failureMessage;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	public void setCardService(CardService cardService) {
		this.cardService = cardService;
	}

	public void setGroupService(GroupService groupService) {
		this.groupService = groupService;
	}

	public abstract String create() throws Exception;

	public abstract String retrieve();

	public abstract String update() throws Exception;

	public abstract String delete() throws Exception;

	public abstract String list();

	@Override
	public String execute() throws Exception {
		return list();
	}
	
	protected Map getSession() {
		Map session = (Map) ActionContext.getContext().get(
				ActionContext.SESSION);
		return session;
	}
}
